﻿using WinFormsMVVM.ViewModels;

namespace WinFormsMVVM.Views
{
    public partial class LoginForm : Form
    {
        private readonly LoginViewModel _viewModel;

        public LoginForm(LoginViewModel viewModel)
        {
            InitializeComponent();
            _viewModel = viewModel;
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            _viewModel.Username = tbUsername.Text.Trim();
            _viewModel.Password = tbPassword.Text.Trim();

            if (_viewModel.LoginCommand.Execute("test"))
            {
                this.Hide();
            }
        }
    }
}
